package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.NetStatusEvent;
	import flash.events.ProgressEvent;
	import flash.media.Video;
	import flash.net.NetConnection;
	import flash.net.NetStream;
	import flash.net.NetStreamAppendBytesAction;
	import flash.net.URLRequest;
	import flash.net.URLStream;
	
	public class BasePlayer extends Sprite
	{
		protected var mNetStream:NetStream;
		protected var mNetConnection:NetConnection;
		protected var mVideo:Video;
		protected var mURLStream:URLStream;
		
		public function BasePlayer(url:String)
		{
			mNetConnection = new NetConnection();
			mNetConnection.connect(null);
			
			mNetStream = new NetStream(mNetConnection);
			mNetStream.client = this;
			mNetStream.addEventListener(NetStatusEvent.NET_STATUS,	onNetStatus);
			
			mVideo = new Video(640, 480);
			mVideo.attachNetStream(mNetStream);
			mVideo.smoothing = true;
			this.addChild(mVideo);
			
			mURLStream = new URLStream();
			mURLStream.addEventListener(Event.OPEN,	onOpen);
			mURLStream.addEventListener(Event.COMPLETE, onComplete);
			mURLStream.addEventListener(ProgressEvent.PROGRESS,onProgress);
			mURLStream.load(new URLRequest(url));
		}
		
		protected function onOpen(event:Event):void{
			trace("onOpen");	
		}
		
		protected function onComplete(event:Event):void{
			trace("onComplete");	
		}
		
		protected function onProgress(event:ProgressEvent):void{
			trace("onProgress", event.toString());	
		}
		
		public function onMetaData(data:Object):void{
			for(var key:String in data){
				trace(key, data[key]);
			}
		}
		
		public function onPlayStatus(data:Object):void{
			trace("onPlayStatus", data); 
		}
		
		protected function onNetStatus(event:NetStatusEvent):void{
			trace("onNetStatus",event.info.code);
		}
	}
}